<template>
  <div id="app">
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>

    <div v-if="!$route.meta.isTop">
    <div class="Top" id="Top" v-show="listTop" @click="ClickTop">
      <van-icon name="upgrade" size=".6rem" color="#1989fa" />
    </div>
    </div>
<!--    <loading v-show="showloading"></loading>-->
  </div>
</template>

<script>
import { bus } from "./utils/http";
import { mapMutations, mapActions } from "vuex";

export default {
  name: "App",
  data() {
    return {
      listTop: false,
      showloading: false,
      channelList: [],
      mobile:1
    };
  },
  created() {
    var browser = {
      versions: (function () {
        var u = navigator.userAgent;
        return {
          trident: u.indexOf("Trident") > -1, //IE内核
          presto: u.indexOf("Presto") > -1, //opera内核
          webKit: u.indexOf("AppleWebKit") > -1, //苹果、谷歌内核
          gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1, //火狐内核
          mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
          ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
          android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1, //android终端或者uc浏览器
          iPhone: u.indexOf("iPhone") > -1, //是否为iPhone或者QQHD浏览器
          iPad: u.indexOf("iPad") > -1, //是否iPad
          webApp: u.indexOf("Safari") == -1, //是否web应该程序，没有头部与底部
          weixin: u.indexOf("MicroMessenger") > -1, //是否微信 （2015-01-22新增）
          qq: u.match(/\sQQ/i) == " qq", //是否QQ
        };
      })(),
      language: (navigator.browserLanguage || navigator.language).toLowerCase(),
    };
    // 判断是否为移动端
    if (browser.versions.mobile || browser.versions.android || browser.versions.ios) {
      localStorage.setItem("ismobile", 1);
      this.mobile=1;
    } else {
      localStorage.setItem("ismobile", 2);
      this.mobile=2;
    }
    if(localStorage.getItem("language") != undefined){
      this.$i18n.locale = localStorage.getItem("language");
    }  else {
      //默认中文
      this.$i18n.locale = "zh";
    }



    var _this = this;
    bus.$on("showloading", function () {
      _this.showloading = true;
    });
    bus.$on("closeLoading", function () {
      _this.showloading = false;
    });
  },
  methods: {

    ...mapMutations(["SET_ISAPPINFO", "SET_LOGIN"]),
    ...mapActions(["Get_userData"]),

    ClickTop() {
      document.documentElement.scrollTop = 0;
      document.body.scrollTop = document.documentElement.scrollTop = 0;
    },
    handleScroll() {
      let t = document.documentElement.scrollTop || document.body.scrollTop;
      if (t > 800) {
        this.listTop = true;
      } else {
        this.listTop = false;
      }
    },
  },
  mounted() {
  // document.title = this.$t(this.$route.meta.title);

    window.addEventListener("scroll", this.handleScroll, true);
  },
  watch: {
    $route(to, from) {
      if(this.$route.meta.title != ''){
      document.title = this.$t(this.$route.meta.title);
      }
    },
  },
};
</script>



<style lang="less">
#app {
  position: relative;
  margin: 0 auto;
  font-size: 0.28rem;
  word-wrap:break-word;
  word-break:normal;
  max-width: 7.5rem;
  background: #F7F9FC;
  color: #4A4C52;
  min-height: 100vh;

  .main_bg {
    background: #fff;
    min-height: 100%;
    color: #4A4C52;
  }
  .h100 {
    height: 1rem;
    margin-top: .4rem;
  }
  .boxshadow {
    background: #ffffff;
    border-radius: .16rem;
    margin-bottom: .2rem;
  }
  .Top {
    z-index: 999999999;
    position: fixed;
    bottom: 1.25rem;
    right: 0.2rem;
  }
  .dialag_box {
    .container {
      width: 6rem;
      margin: 0 auto;
      border-radius: .12rem;
      padding: .4rem .58rem;
      .name {
        font-size: .32rem;
        font-weight: 500;
        color: #1b1f2e;
        line-height: .35rem;
      }
      .con {
        padding: .2rem 0;
        font-size: .26rem;
        font-weight: 400;
        color: #14191f;
        line-height: .4rem;
        span {
          color: #999;
          display: block;
          margin: .1rem 0 0 0;
        }
      }
      .b {
        margin: 0 -.1rem;
        padding-top: .1rem;
        .flex {
          padding: 0 .1rem;
        }
        button {
          height: .76rem;
          display: block;
          width: 100%;
          background: linear-gradient(-90deg,rgba(5,59,194,0.1)0%, rgba(34,149,237,0.1) 100%);
          border-radius: .12rem;border:0;
          color: #2A64E4;
        }
        .btn {
          opacity: 1;
          color: #fff;
          background: linear-gradient(-90deg,#053bc2 0%, #2295ed 100%);
        }
      }
    }
  }

  .tname {
    text-align: center;
    height: 1rem;
    font-size: .34rem;
    color: #14191f;
    line-height: 1rem;
    .abs {
      right: .3rem;
      top:.06rem;
      i {
        font-size: .4rem;
        color: #666;
      }
    }
  }
  //通用从下弹出状态框
  .pop_bg {
    background: rgba(0, 0, 0, 0.8);
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 101;
    top: 0;
    left: 0;
  }
  .order_pop {
    .tip {
      font-size: 0.26rem;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      padding-top: 0.3rem;
      padding-bottom: 0.1rem;
      img {
        height: 0.32rem;
        margin-right: 0.1rem;
      }
    }
  }
  .pop_box {
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 102;
    border-radius: 0.32rem 0.32rem 0 0;

    .title {
      height: 1rem;
      line-height: 1rem;
      border-bottom: 0.02rem solid rgba(243, 243, 243, 1);
      h3 {
        font-size: 0.3rem;
        font-weight: 400;
        color: rgba(20, 25, 31, 1);
      }
      .abs {
        top: 0.27rem;
        right: 0.3rem;
        width: 0.44rem;
        height: 0.44rem;
      }
    }
  }

  //列表为空显示的状态
  .empty {
    text-align: center;
    padding-top: 1.4rem;
    img {
      height: 2rem;
    }
    span {
      display: block;
      color: #999;
      margin-top: 0.4rem;
    }
  }

  //通用列表式
  .a_list {
    margin-bottom: 0.2rem;
    li {
      border-bottom: 1px solid #D8D8D8;
      padding: 0 0.32rem;
      &:last-child {
        border:0;
      }
      .flex {
        font-size: 0.3rem;
        font-weight: 400;
        line-height: 1rem;
      }
      .str {
        span {
          display: block;
          width: 0.4rem;
          height: 0.4rem;
          background: url(assets/images/set/i_check_off.png) no-repeat;
          background-size: 100% 100%;
        }
      }
      textarea {
        height: 3rem;
        padding: 0.3rem 0;
        border: 0;
        font-size: 0.3rem;
        width: 100%;
      }
    }
    li.on {
      .str {
        span {
          background-image: url(assets/images/set/ico_check_on2.png);
        }
      }
    }
  }




}
</style>
